<?php
session_start();
ob_start();
include_once 'include/common.php';

global $core;
$core = new core();
$customer_order_id = isset($_GET["id"]) ? intval($_GET["id"]) : 0;
$code = isset($_GET["code"]) ? trim($_GET["code"]) : '';

$customer_order = $core->getCustomerOrderDetailById($customer_order_id);
$not_found = true;
$order_name = '';

if ($customer_order) {


    //get info customer

    foreach ($customer_order as $order_detail) {

        $customer_phone = $order_detail->phone;
        $customer_fb_name = stripslashes($order_detail->facebook_name);
        $customer_name = stripslashes($order_detail->name);
        $customer_email = stripslashes($order_detail->email);
        $customer_wholesale = $order_detail->wholesale;
        $customer_address = stripslashes($order_detail->address);
        $customer_province = $order_detail->province;
        $customer_id = $order_detail->customer_id;
        $order_description = stripslashes($order_detail->order_description);
        $type_calculate_payment = $order_detail->type_calculate_payment;
        $service_percent = $order_detail->service_percent;
        $fee_per_kg = $order_detail->fee_per_kg;
        $weight = $order_detail->weight;
        $exchange = $order_detail->exchange;
        $total_payment = $order_detail->total_payment;
        $total_order_money = $order_detail->total_order_money;
        $total_current_money = $order_detail->total_current_money;
        $total_pt = $order_detail->total_store_price;
        $total_at = $order_detail->total_stamp_price;
        if ($order_detail->code_view == $code) {
            $not_found = false;
            $order = $core->getOrderById($order_detail->zen_order_id);
            if ($order) {
                $order_name = $order->zen_order_name;
            }


        }
        break;

    }


    $html_list_product = '';
    $total_product_order = 0;
    $total_product_buy=0;

    if ($customer_order && $not_found == false) {

        $html_list_product .= ' <table id="example" class="table  " cellspacing="0" width="100%" style="color: #d3e7fe">
                        <thead>
                        <tr style="color: #fff">
                            <th style="text-align: center">Ảnh</th>
                            <th style="text-align: center">Mã Sản Phẩm</th>

                            <th style="text-align: center">Màu</th>
                            <th style="text-align: center">Size</th>
                            <th style="text-align: center">Số Lượng (Đặt mua/ Mua được)</th>
                             <th style="text-align: center">Tình Trạng</th>
                              <th style="text-align: center">Ghi chú</th>';

        if($type_calculate_payment=='pt'){
            $html_list_product.='<th style="text-align: center">Giá (EU)</th>';
        }else{
            $html_list_product.='<th style="text-align: center">Giá (VNĐ)</th>';
        }

         $html_list_product.='</tr>
                        </thead>


                        <tbody>';

        foreach ($customer_order as $order_detail) {
            if($order_detail->order_status==6){
                $total_product_order = $total_product_order + $order_detail->product_num;
            }else{
                $total_product_order = $total_product_order + $order_detail->product_num;
                $total_product_buy= $total_product_buy + $order_detail->product_num;
            }
            $color_photo_name = $order_detail->product_color . "_" . $order_detail->product_code . "_" . $order_detail->manufacture;
            $color_photo_name = $core->convert_string_friendly($color_photo_name) . ".jpg";
            $path_color_photo =  "vanhuynh".DS."photo" . DS . "extra_photo" . DS . "thumb_extra_photo" . DS . $color_photo_name;

            if (file_exists($path_color_photo)) {
                $src_photo_thumb = 'vanhuynh'.DS.'photo'.DS.'extra_photo'.DS.'thumb_extra_photo'.DS.'' . $color_photo_name;
            } else {
                $src_photo_thumb = 'vanhuynh'.DS.'photo'.DS.'thumb_photo'.DS.'200_' . $order_detail->main_photo;
            }

            $status = '';
            switch ($order_detail->order_status) {
                case 0:
                case 1:
                    $status = 'OK';
                    break;
                case 2:
                    $status = 'Hàng có sẵn';
                    break;
                case 3:
                    $status = 'Đã nhận hàng';
                    break;
                case 4:
                    $status = 'Shipping';
                    break;
                case 5:
                    $status = 'Bạn đã nhận';
                    break;
                case 6:
                    $status = '<p style="color:red;font-size:20px;">Hết hàng</p>';
                    break;
                case 7:
                    $status = 'Đang xử lí';
                    break;
                case 8:
                    $status = 'Bạn chưa chắc chắn mua';
                    break;
            }

            switch($type_calculate_payment){
                case 'normal':
                    $price_per_product = $order_detail->product_price;
                    break;
                case 'at':
                    $price_per_product = $order_detail->product_price;
                    //$price_per_product = $order_detail->stamp_price;
                   // $price_per_product = $order_detail->stamp_price*$exchange;
                    break;
                case 'pt':
                    $price_per_product = $order_detail->store_price;
                    //$price_per_product = $order_detail->store_price*$exchange;
                    break;
                default:
                    $price_per_product = 0;
                    break;
            }

            $html_list_product.=' <tr >
                            <td style="text-align: center"><img src="' . $src_photo_thumb . '" alt=""
                                             style="border-radius: 25px;height:100px" width="100px" height="100px"></td>
                            <td style="text-align: center">' . $order_detail->product_code . '</td>
                            <td style="text-align: center"><b>' . stripslashes($order_detail->product_color) . ' </b></td>
                            <td style="text-align: center"> <b>' . stripslashes($order_detail->product_size) . '</b></td>
                            <td style="text-align: center">
                                <b>'.$order_detail->order_product_num .'</b> / <b>'.$order_detail->product_num .'</b>

                            </td>
                             <td style="text-align: center">'.$status.'</td>
                             <td style="text-align: center">'.$order_detail->description.'</td>
                             <td style="text-align: center">  <b>'.number_format($price_per_product).'</b></td>
                        </tr>';


        }

        $html_list_product .= '</tbody></table>';

    } else {
        $html_list_product = '<b>Không tìm thấy đơn hàng của bạn, vui lòng liên hệ lấy lại link đúng.</b>';
    }

    $total_paid = $total_order_money - $total_payment;
    if($total_paid > 0){
        $money_paid = "Thiếu ".number_format($total_paid)." VNĐ";
    }else{
        $money_paid = 'Thừa '.number_format($total_paid*(-1)).' VNĐ';
    }

}

$list_random_product = $core->getRandomProduct(5);

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>About</title>
    <meta charset="utf-8">
    <link rel="icon" href="#" type="image/x-icon">
    <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon"/>
    <meta name="description" content="Your description">
    <meta name="keywords" content="Your keywords">
    <meta name="author" content="Your name">
    <link rel="stylesheet" href="css/bootstrap.css" type="text/css" media="screen">
    <link rel="stylesheet" href="css/responsive.css" type="text/css" media="screen">
    <link rel="stylesheet" href="css/style.css?v=2" type="text/css" media="screen">
    <link rel="stylesheet" href="css/touchTouch.css" type="text/css" media="screen">
    <link rel="stylesheet" href="css/kwicks-slider.css" type="text/css" media="screen">
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300' rel='stylesheet' type='text/css'>
    <link rel='stylesheet' id='camera-css' href='css/camera.css' type='text/css' media='all'>

    <script type="text/javascript" src="js/jquery.js?v=1"></script>
    <script type="text/javascript" src="js/superfish.js"></script>
    <script type="text/javascript" src="js/jquery.flexslider-min.js"></script>
    <script type="text/javascript" src="js/jquery.kwicks-1.5.1.js"></script>
    <script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
    <script type="text/javascript" src="js/touchTouch.jquery.js"></script>
<!--    <script type='text/javascript' src='js/camera.js'></script>-->

    <script type="text/javascript">if ($(window).width() > 1024) {
            document.write("<" + "script src='js/jquery.preloader.js'></" + "script>");
        }    </script>

    <script>
        jQuery(window).load(function () {
            $x = $(window).width();
            if ($x > 1024) {
                jQuery("#content .row").preloader();
            }

            jQuery('.magnifier').touchTouch();
            jQuery('.spinner').animate({'opacity': 0}, 1000, 'easeOutCubic', function () {
                jQuery(this).css('display', 'none')
            });
//            $('.camera_wrap').camera({ //here I declared some settings, the height and the presence of the thumbnails
//                height: '60%',
//                pagination: true,
//                thumbnails: false
//            });
        });


    </script>

    <!--[if lt IE 8]>
    <div style='text-align:center'><a
        href="http://www.microsoft.com/windows/internet-explorer/default.aspx?ocid=ie6_countdown_bannercode"><img
        src="http://www.theie6countdown.com/img/upgrade.jpg" border="0" alt=""/></a></div>
    <![endif]-->
    <!--[if (gt IE 9)|!(IE)]><!-->
    <!--<![endif]-->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <link rel="stylesheet" href="css/ie.css" type="text/css" media="screen">
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:300' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:400' rel='stylesheet' type='text/css'>
    <![endif]-->
</head>

<body>
<div class="spinner"></div>
<!--============================== header =================================-->
<header>
    <div class="container clearfix">
        <div class="row">
            <div class="span12">
                <div class="navbar navbar_">
                    <div class="container">
                        <h1 class="brand brand_"><a href="index.html">
                                <!--                                <img alt="" src="img/logo.gif"> -->
                            </a></h1>
                        <a class="btn btn-navbar btn-navbar_" data-toggle="collapse" data-target=".nav-collapse_">Menu
                            <span class="icon-bar"></span> </a>

                        <div class="nav-collapse nav-collapse_  collapse">
                            <ul class="nav sf-menu">
                                <li class="active"><a href="#">Home</a></li>
                                <!--                                <li class="sub-menu"><a href="index-1.html">Services</a>-->
                                <!--                                    <ul>-->
                                <!--                                        <li><a href="#">Dolore </a></li>-->
                                <!--                                        <li><a href="#">Consecte</a></li>-->
                                <!--                                        <li><a href="#">Conseq</a></li>-->
                                <!--                                    </ul>-->
                                <!--                                </li>-->
                                <!--                                <li><a href="index-2.html">Folio</a></li>-->
                                <!--                                <li><a href="index-3.html">Blog</a></li>-->
                                <!--                                <li><a href="index-4.html">Contact</a></li>-->
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</header>
<div class="bg-content">
    <div class="container">
        <div class="row">
            <div class="span12">
                <!--============================== slider =================================-->


                <!--                <div class="camera_wrap camera_magenta_skin" id="camera_wrap_2">-->
                <!--                    --><?php
                //                    foreach ($list_random_product as $product) {
                //
                //                        echo '<div data-thumb="vanhuynh/photo/' . $product['photo'] . '" data-src="vanhuynh/photo/' . $product['photo'] . '">
                //                                        <div class="camera_caption fadeFromBottom">
                //                                           Mã sản phẩm: <b>' . $product['code'] . '</b>. <em><a href="' . $product['link'] . '">Link gốc</a></em>
                //                                        </div>
                //                                    </div>';
                //
                //                    }
                //                    ?>
                <!---->
                <!--                </div>-->
                <!-- #camera_wrap_2 -->
                <div class="flexslider">
                    <ul class="slides">
                        <li> <img src="images/slider/banner.jpg" alt="" > </li>
                        <li> <img src="images/slider/aa.jpg" alt="" > </li>
                        <li> <img src="images/slider/bb.jpg" alt="" > </li>
                        <li> <img src="images/slider/cc.jpg" alt="" > </li>
                        <li> <img src="images/slider/dd.jpg" alt="" > </li>
                        <li> <img src="images/slider/ee.jpg" alt="" > </li>
                        <li> <img src="images/slider/ff.jpg" alt="" > </li>
                    </ul>
                </div>
                <span id="responsiveFlag"></span>

                <div class=" row " style="margin-left: 10px">


                    <div style="color:#fff;font-size: 16px">
                        <?php
                        if ($order_name != '' && $not_found == false) {
                            ?>
                            <p>Đợt hàng <b><?php echo $order_name; ?></b></p>

                            <p><b><?php echo $customer_fb_name; ?></p>
                            <p><?php echo $customer_address ?></p>
                            <p>Mobile: <b><?php echo $customer_phone; ?> </b></p>
                        <?php

                        }
                        ?>

                    </div>
                </div>
                <div class="row">
                    <?php
                    if( $not_found == false){
                        if($type_calculate_payment=='pt'){
                    ?>
                            <!--table-striped table-bordered-->
                            <table id="example" class="table table-bordered " cellspacing="0" width="100%">
                                <thead>
                                <tr style="color: #fff">
                                    <th>SP đặt mua</th>
                                    <th>SP mua được</th>
                                    <th>Cân nặng ( phí VC/KG)</th>
                                    <th>Phí</th>
                                    <th>Tổng tiền đơn hàng</th>
                                    <th>Tổng(đơn hàng+ phí+ KG)</th>
                                    <th>Tiền cọc</th>
                                    <th>Tiền thanh toán</th>
                                    <th>Tỉ giá</th>
                                </tr>
                                </thead>


                                <tbody>
                                <tr style="color: #fff">
                                    <td style="text-align: center"><?php echo $total_product_order; ?></td>
                                    <td style="text-align: center"><?php echo $total_product_buy; ?></td>
                                    <td style="text-align: center"><?php echo $weight." KG ( ".number_format($fee_per_kg)." EU / KG)"; ?></td>
                                    <td style="text-align: center"><?php echo $service_percent; ?> %</td>
                                    <td style="text-align: center"><?php echo number_format($total_pt); ?> EU</td>
                                    <td><?php echo number_format($total_order_money) . " VNĐ"; ?></td>
                                    <td><?php echo number_format($total_payment) . ' VNĐ'; ?></td>
                                    <td><?php echo $money_paid; ?></td>
                                    <td style="text-align: center"><?php echo number_format($exchange); ?> VNĐ/EU</td>
                                </tr>
                                </tbody>
                            </table>
                    <?php

                        }else {


                    ?>
                            <!--table-striped table-bordered-->
                            <table id="example" class="table table-bordered " cellspacing="0" width="100%">
                                <thead>
                                <tr style="color: #fff">
                                    <th>Sản phẩm đặt mua</th>
                                    <th>Sản phẩm mua được</th>
                                    <!--                            <th>Tiền đặt mua</th>-->
                                    <th>Tổng tiền</th>
                                    <th>Tiền cọc</th>
                                    <th>Tiền thanh toán</th>
<!--                                    <th>Tỉ giá</th>-->
                                </tr>
                                </thead>


                                <tbody>
                                <tr style="color: #fff">
                                    <td style="text-align: center"><?php echo $total_product_order; ?></td>
                                    <td style="text-align: center"><?php echo $total_product_buy; ?></td>
                                    <!--                            <td>-->
                                    <?php //echo number_format($total_price_order)." VNĐ";?><!--</td>-->
                                    <td>
                                        <?php
                                            if($type_calculate_payment=='at'){
                                                echo number_format($total_at) . " EU";
                                            }else{
                                                echo number_format($total_order_money) . " VNĐ";
                                            }

                                        ?>
                                    </td>
                                    <td><?php echo number_format($total_payment) . ' VNĐ'; ?></td>
                                    <td><?php echo $money_paid; ?></td>
<!--                                    <td style="text-align: center">--><?php //echo number_format($exchange); ?><!-- VNĐ/EU</td>-->
                                </tr>
                                </tbody>
                            </table>
                    <?php
                        }
                    }
                    ?>
                </div>
            </div>
        </div>
    </div>

    <!--============================== content =================================-->

    <div id="content" class="content-extra">
        <div class="ic">More Website Templates @ TemplateMonster.com. November19, 2012!</div>
        <div class="row-1">
            <div class="container">
                <div class="row">
                    <?php
                    if( $not_found == false){
                        echo $html_list_product;
                    }
                    ?>


                </div>
            </div>
        </div>

    </div>
</div>

<!--============================== footer =================================-->
<footer style="">
    <div class="container clearfix">
        <!--        <ul class="list-social pull-right">-->
        <!--            <li><a class="icon-1" href="#"></a></li>-->
        <!--            <li><a class="icon-2" href="#"></a></li>-->
        <!--            <li><a class="icon-3" href="#"></a></li>-->
        <!--            <li><a class="icon-4" href="#"></a></li>-->
        <!--        </ul>-->
        <!--        <div class="privacy pull-left">-->
        <!--            -->
        <!---->
        <!--        </div>-->
        <div class="row">
            <div class="span5">
                <p>Zen EU</p>

                <p>Address : 2A ngõ 126 Hoàng Hoa Thám - Hà nội</p>

                <p>Tel + Viber: 0942666200</p>

                <p>Email: <a href="mailto:zen.shop.eu@gmail.com">zen.shop.eu@gmail.com</a></p>

                <p>Tài khoản VCB : 0491000018767 - Chủ Tài khoản : Phan Thanh Huỳnh - Chi nhánh : Thăng Long Hà
                    nội</p>
            </div>
            <div class="span7" style="text-align: right;">
                <iframe width='300' height='300' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.vietbando.com/maps/vbdEmbed.aspx?t=3&st=0&sk=126+%c4%91%c6%b0%e1%bb%9dng+ho%c3%a0ng+hoa+th%c3%a1m,+ph%c6%b0%e1%bb%9dng+th%e1%bb%a5y+khu%c3%aa,+qu%e1%ba%adn+t%c3%a2y+h%e1%bb%93,+th%c3%a0nh+ph%e1%bb%91+h%c3%a0+n%e1%bb%99i&l=17&kv=21.0420667,105.823648&iwloc=2&cl=831726&sb' style='color:#D98923;'>Xem bản đồ lớn</a></small>
            </div>
        </div>
</footer>
<script type="text/javascript" src="js/bootstrap.js"></script>
</body>
</html>

